<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>tablecopy</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="table3.html" title="table3" />
    <link rel="next" href="tablefilter.html" title="tablefilter" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">tablecopy</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="table3.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="tablefilter.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="tablecopy"></a>
      <div class="titlepage"></div>
      <a id="IndexTablecopy" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">tablecopy</span>
        </h2>
        <p>tablecopy — 
      Simple, fast table copy opcode.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp155282016"></a>
        <h2>Description</h2>
        <p>
      Simple, fast table copy opcode.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp155283232"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>tablecopy</strong></span> kdft, ksft</pre>
      </div>
      <div class="refsect1">
        <a id="idp155285280"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kdft</em></span> -- Destination function table.
    </p>
        <p>
      <span class="emphasis"><em>ksft</em></span> -- Number of source function table.
    </p>
        <p>
      <span class="emphasis"><em>tablecopy</em></span> -- Simple, fast table copy opcode. Takes the table length from the destination table, and reads from the start of the source table. For speed reasons, does not check the source length - just copies regardless - in <span class="quote">“<span class="quote">wrap</span>”</span> mode. This may read through the source table several times. A source table with length 1 will cause all values in the destination table to be written to its value.
    </p>
        <p>
      <span class="emphasis"><em>tablecopy</em></span> cannot read or write the guardpoint. To read it use <a class="link" href="table.html" title="table"><em class="citetitle">table</em></a>, with <span class="emphasis"><em>ndx</em></span> = the table length. Likewise use table write to write it.
    </p>
        <p>
      To write the guardpoint to the value in location 0, use <a class="link" href="tablegpw.html" title="tablegpw"><em class="citetitle">tablegpw</em></a>.
    </p>
        <p>
      This is primarily to change function tables quickly in a real-time situation.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp155293552"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the tablecopy opcode. It uses the file <a class="ulink" href="examples/tablecopy.csd" target="_top"><em class="citetitle">tablecopy.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp155295408"></a>
          <p class="title">
            <strong>Example 895. Example of the tablecopy opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac    <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o tablecopy.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span>  <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1
<span class="comment">;after an example from Jonathan Murphy </span>
  
gilen <span class="op">=</span> 7
gilist  <span class="ohdr">ftgen</span> 1, 0, gilen <span class="op">+</span> 1, <span class="op">-</span>2, 2, 3, 4, 5, 6, 7	<span class="comment">;only 6 elements, so 1 is doubled</span>
gitmp   <span class="ohdr">ftgen</span> 2, 0, gilen <span class="op">+</span> 1, <span class="op">-</span>2, 0			<span class="comment">;empty table</span>
gkmax   <span class="opc">init</span> gilen

<span class="ohdr">seed</span> 0							<span class="comment">;each time different </span>

<span class="oblock">instr</span> 1

ktrig <span class="opc">metro</span> 3						<span class="comment">;trigger values</span>
krnd  <span class="opc">random</span> 0, gkmax

<span class="octrl">if</span> (ktrig <span class="op">==</span> 1) then
  kval    <span class="opc">table</span>  krnd, gilist
          <span class="opc">tablew</span> 0, krnd, gilist
  kread   <span class="op">=</span> 0
  kwrite  <span class="op">=</span> 0
<span class="olabel">start</span><span class="op">:</span>
  knew    <span class="opc">table</span> kread, gilist
<span class="octrl">if</span> (knew <span class="op">!=</span> 0) then
          <span class="opc">tablew</span> knew, kwrite, gitmp
  kwrite    <span class="op">=</span>  kwrite <span class="op">+</span> 1
<span class="octrl">endif</span>
  kread   <span class="op">=</span> kread <span class="op">+</span> 1
<span class="octrl">if</span> (kread <span class="op">&lt;=</span> gilen) <span class="octrl">kgoto</span> <span class="olabel">start</span>
          <span class="opc">tablecopy</span> gilist, gitmp			<span class="comment">;fill with zeroes</span>
  gkmax   <span class="op">=</span> gkmax <span class="op">-</span> 1
<span class="octrl">endif</span>

<span class="opc">printk2</span> kval

<span class="octrl">if</span> (gkmax <span class="op">&lt;</span> 0) then
          <span class="opc">event</span> "i", 2, 0, 1<span class="op">/</span><span class="ohdr">kr</span>				<span class="comment">;when ready, then stop</span>
<span class="octrl">endif</span>

asig <span class="opc">vco2</span> .5, 40<span class="op">*</span>kval					<span class="comment">;sound generation</span>
<span class="opc">outs</span> asig, asig
    
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2

<span class="opc">exitnow</span>
    
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span>1 0 5
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
      Its output should include a lines like these:
</p>
        <pre class="screen">
i1     5.00000
i1     3.00000
i1     2.00000
i1     4.00000
i1     7.00000
i1     6.00000
i1     7.00000</pre>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp155300512"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="tablegpw.html" title="tablegpw"><em class="citetitle">tablegpw</em></a>,
      <a class="link" href="tablemix.html" title="tablemix"><em class="citetitle">tablemix</em></a>,
      <a class="link" href="tableicopy.html" title="tableicopy"><em class="citetitle">tableicopy</em></a>,
      <a class="link" href="tableigpw.html" title="tableigpw"><em class="citetitle">tableigpw</em></a>,
      <a class="link" href="tableimix.html" title="tableimix"><em class="citetitle">tableimix</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp155306432"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Robin Whittle</td>
          </tr>
          <tr>
            <td>Australia</td>
          </tr>
          <tr>
            <td>May 1997</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 3.47</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="table3.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="tablefilter.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">table3 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> tablefilter</td>
        </tr>
      </table>
    </div>
  </body>
</html>
